package com.hhd.flow.controller;

import com.hhd.flow.engine.FlowEngine;
import com.hhd.flow.entity.FlowUserTask;
import com.hhd.flow.utils.CommonUtils;
import com.hhd.flow.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/flow")
public class FlowCommonController {
    @Autowired
    FlowEngine flowEngine;

    @GetMapping("/getFlowUserTaskById")
    public Result getFlowUserTaskById(String flowUserTaskId) {
        FlowUserTask flowUserTask = flowEngine.getFlowUserTaskService().getById(flowUserTaskId);
        if (!CommonUtils.isEmpty(flowUserTask)) return Result.ok(flowUserTask);
        return Result.ok(flowEngine.getFlowUserTaskHistoryService().getById(flowUserTaskId));
    }
}
